/**
 * @filename:StudentServiceImpl Student
 * @project constract  V1.0
 * Copyright(c) 2018 lin keqing Co. Ltd.
 * All right reserved.
 */
package com.znufe.exam.service.impl;

import java.util.List;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.znufe.exam.domain.students.StudentResponseObject;
import com.znufe.exam.domain.students.StudentValidationObject;
import com.znufe.exam.domain.students.StudentVoteInfoObject;
import com.znufe.exam.repository.StudentMapper;
import com.znufe.exam.viewmodel.admin.student.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.znufe.exam.domain.Student;
import com.znufe.exam.service.StudentService;

/**
 *
 * @Description:  学生信息表——SERVICEIMPL
 * @Author:       lin keqing
 * @CreateDate:   Student
 * @Version:      V1.0
 *
 */
@Service
public class StudentServiceImpl extends BaseServiceImpl<Student> implements StudentService {

	private final StudentMapper studentMapper;

	@Autowired
	public StudentServiceImpl(StudentMapper studentMapper) {
		super(studentMapper);
		this.studentMapper = studentMapper;
	}

	//查询对象
	@Override
	public Student selectByPrimaryKey(Integer id) {
		return studentMapper.selectByPrimaryKey(id);
	}

	@Override
	public Student selectByStuName(String stuName) {
	    return studentMapper.selectByStuName(stuName);
    }

	//删除对象
	@Override
	public int deleteByPrimaryKey(Integer id) {
		return studentMapper.deleteByPrimaryKey(id);
	}

	//添加对象
	@Override
	public int insertSelective(Student student) {
		return studentMapper.insertSelective(student);
	}

	//修改对象
	@Override
	public int updateByPrimaryKeySelective(Student student) {
		return studentMapper.updateByPrimaryKeySelective(student);
	}

	// 整合页面的查询（通过班级名称/学生姓名查找）
	@Override
	public PageInfo<StudentResponseObject> studentPage(StudentPageRequestVM requestVM) {
		return PageHelper.startPage(requestVM.getPageNum(), requestVM.getPageSize(),
				"id desc").doSelectPageInfo(() ->
				studentMapper.studentPage(requestVM));
	}

	@Override
	public PageInfo<StudentSignInResponseVM> studentSignInPage(StudentSignInRequestVM requestVM) {
		return 	PageHelper.startPage(requestVM.getPageNum(), requestVM.getPageSize())
					.doSelectPageInfo(() ->
					studentMapper.studentSignInPage(requestVM));
	}

	@Override
	public RandomStudentResponseVM getRandomStudent(RandomStudentRequestVM requestVM) {
		return studentMapper.selectRandomStudentByClassId(requestVM);
	}

	//查询集合
	@Override
	public List<Student> queryStudentList(Student student) {
		return studentMapper.queryStudentList(student);
	}

    @Override
	public Student selectByStuPhone(String stuPhone) {
		return studentMapper.selectByStuPhone(stuPhone);
	}

	@Override
	public List<StudentValidationObject> selectValidationByClassId(Integer classId) {
		return studentMapper.selectValidationByClassId(classId);
	}

	@Override
	public int insertBatchStudent(List<Student> studentsToImport) {
		return studentMapper.insertBatchStudent(studentsToImport);
	}

	@Override
	public Student selectByVoteIdInClass(Integer classId, String voteId) {
		return studentMapper.selectByVoteIdInClass(classId, voteId);
	}

	@Override
	public List<StudentVoteInfoObject> selectAllStudentVoteInfoInClass(Integer classId) {
		return studentMapper.selectAllStudentVoteInfoInClass(classId);
	}
}
